package view;

import model.LessonGuide;
import eventHandling.Callback;
import eventHandling.EventBus;
import eventHandling.EventTyp.Type;

/**
 * Controller for the StatisticsPanel.
 * 
 * @author sloth42
 *
 */
public class StatisticsPanelController implements Controller {

	private StatisticsPanel statsPanel;
	private EventBus eventBus;
	private LessonGuide lessonGuide;

	public StatisticsPanelController(EventBus eventBus,
			StatisticsPanel statsPanel, LessonGuide lessonGuide) {
		this.eventBus = eventBus;
		this.statsPanel = statsPanel;
		this.lessonGuide = lessonGuide;
		registerForEvents();
	}

	private void registerForEvents() {
		eventBus.register(Type.ADD_NEW_CARD, new Callback() {

			public void actionPerformed() {
				
				statsPanel.addBar("test", lessonGuide.getNumberOfExpiredCards(),
						lessonGuide.getNumberOfUnLearnedCards(),
						lessonGuide.getNumberOfLearnedCards());
				statsPanel.repaint();
				
//				statsPanel.updateOverallBar(lessonGuide.getNumberOfExpiredCards(),
//						lessonGuide.getNumberOfUnLearnedCards(),
//						lessonGuide.getNumberOfLearnedCards());
			}
		});
	}
}
